<template>
	<view class="">
		<u-navbar :is-back="true" title="新增学员" back-icon-color="#ffffff" :background="{backgroundColor:'#E62131'}"
			title-color="#ffffff"></u-navbar>
		<view class="clasforms">
			<u-form :model="form" ref="uForm" label-width="150rpx">
				<!-- <u-form-item label="上课日期"><u-input v-model="form.classDate" type="select" :disabled="true"
						@click="isdatemodals(1)" /></u-form-item>
				<u-form-item label="上课时间"><u-input v-model="form.classStartTime" type="select" :disabled="true"
						@click="isdatemodals(2)" /></u-form-item>
				<u-form-item label="授课教练"><u-input v-model="form.coachId" type="select" :disabled="true"
						@click="isdatemodals(3)" /></u-form-item> -->
				<!-- <u-form-item label="上课科目"><u-input v-model="form.sex" type="select" /></u-form-item> -->
				<u-form-item label="学员姓名"><u-input v-model="form.classHours" /></u-form-item>
				<u-form-item label="学员电话"><u-input v-model="form.classDuration" /></u-form-item>
				<u-form-item label="校区"><u-input v-model="form.classStartTime" /></u-form-item>
				<u-form-item label="备注"><u-input v-model="form.remarks" /></u-form-item>
			</u-form>
		</view>
		<u-picker mode="time" v-model="dateshow" :params="params" @confirm="confirm"></u-picker>
		<u-picker mode="time" v-model="timeshow" :params="timeparams" @confirm="tiemconfirm"></u-picker>
		<u-select v-model="coachshow" :list="list" @confirm="coachconfirm" value-name="id"
			label-name="nickName"></u-select>

		<view class="bneads w-btn-fixed">
			<div class="btnlst fliexs space_between">
				<view class="btn_left right" @click="endkecheng">
					保存
				</view>
			</div>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dateshow: false,
				params: {
					year: true,
					month: true,
					day: true,
					hour: false,
					minute: false,
					second: false
				},
				timeshow: false,
				timeparams: {
					year: false,
					month: false,
					day: false,
					hour: true,
					minute: true,
					second: true
				},
				coachshow: false,
				list: [],
				form: {
					classDate: '',
					classStartTime: '',
					coachId: '',
					classHours: '',
					classDuration: '',
					remarks: '',
				},
				usersparms: {
					limit: 3000,
					page: 1,
					keyword: "",
					roleId: 2,
				},
			}
		},
		onLoad(option) {

			// this.userslistApi()
			// this.form = JSON.parse(option.item)
			// this.form.classDate = this.form.classYear + '-'+this.form.classDate

		},
		methods: {
			endkecheng() {
				uni.$api.common.endworkout(this.form).then((res) => {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					setTimeout(() => {
						uni.navigateBack({
							delta: 1,
						})
					}, 2000)
				});
			},
			userslistApi() {
				uni.$api.common.userslist(this.usersparms).then((res) => {
					this.list = res.result
				});
			},
			isdatemodals(index) {
				if (index == 1) {
					this.dateshow = true;
				}
				if (index == 2) {
					this.timeshow = true;
				}
				if (index == 3) {
					this.coachshow = true;
				}
			},
			confirm(e) {
				this.form.classDate = e.year + '-' + e.month + '-' + e.day
			},
			tiemconfirm(e) {
				this.form.classStartTime = e.hour + '-' + e.minute + '-' + e.second
			},
			coachconfirm(e) {
				this.form.coachId = e[0].value
			},
		}
	};
</script>
<style lang="scss">
	.clasforms {
		padding: 20rpx;
	}

	.btnlst {
		// margin-top: 350rpx;

		.btn_left {
			width: 100%;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			color: #b1b1b1;
			border: 1rpx solid #e1e1e1;
		}

		.right {
			background-color: #E62131;
			color: #ffffff;
		}
	}

	.bgfenge {
		width: 100%;
		height: 10rpx;
		background-color: #f4f4f4;
	}

	.padingist {
		padding: 10rpx 30rpx 120rpx;
	}

	.topps {
		color: #b1b1b1;
		padding: 20rpx 0;
	}
</style>